package com.iot.service.mqtt.service.auth;

import com.iot.service.mqtt.service.auth.fix.FixTlAuthentication;
import com.iot.service.mqtt.service.auth.http.HttpTlAuthentication;
import com.iot.service.mqtt.service.auth.sql.SqlTlAuthentication;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @Author: hszhou
 * @Date: 2025/1/17 17:16
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
@Service
@RequiredArgsConstructor
public class AuthenticationService {


    /**配置文件认证*/
    private final FixTlAuthentication fixTlAuthentication;
    /**http接口认证*/
    private final HttpTlAuthentication httpTlAuthentication;
    /**无认证*/
    private final NoneAuthenticationService noneAuthenticationService;
    /**sql认证*/
    private final SqlTlAuthentication sqlTlAuthentication;

    /**
     *
     * @author 认证
     * @datetime: 2025-05-10 16:16:44
     * @param username 用户名
     * @param password 密码
     * @return boolean
     **/
    public boolean auth(String username,String password){
        noneAuthenticationService.setNextAuthentication(fixTlAuthentication);
        fixTlAuthentication.setNextAuthentication(httpTlAuthentication);
        httpTlAuthentication.setNextAuthentication(sqlTlAuthentication);
       return noneAuthenticationService.execute(username,password);
    }
}
